import request from './request' 
// import $axios from './request'


//封装登陆接口
export function login(data) {
    return request({
        url: '/login',
        method: 'POST',
        data
    })
}

//封装左侧菜单列表
export function menu() {
    return request({
        url: '/menus',
        method: 'GET',
    })
}

//封装用户列表
export function getUsersListApi(params) {
    return request({
        url: '/users',
        method: 'GET',
        params
    })
}

//封装添加用户
export function getAddUser(data) {
    return request({
        url: '/users',
        method: 'post',
        data
    })
}

//封装编辑用户
export function getCompile(id, data) {
    return request({
        url: `/users/${id}`,
        method: 'PUT',
        data
    })
}

//封装删除用户
export function getRemove(id) {
    return request({
        url: `/users/${id}`,
        method: 'delete',
    })
}


//封装修改用户状态
// export const getStatus = async (uid,type)=>{
//     let {data}=await $axios.put(`/users/${uid}/state/${type}`)
//     return data
// }
export function getStatus(uid, type) {
    return request({
        url: `/users/${uid}/state/${type}`,
        method: 'put',
    })
}

//封装分配角色列表
export function getRoleList() {
    return request({
        url: '/roles',
        method: 'get',
    })
}

//分配角色给用户接口
export function getUserAPI(id, data) {
    return request({
        url: `/users/${id}/role`,
        method: 'put',
        data
    })
}

//封装权限列表
export function getType(type) {
    return request({
        url: `rights/${type}`,
        method: 'get',
    })
}

//添加用户角色接口
export function getRoleApi(data) {
    console.log(data);
    return request({
        url: '/roles',
        method: 'post',
        data
    })
}

//封装角色编辑用户接口
export function getEdit(id, data) {
    return request({
        url: `/roles/${id}`,
        method: 'PUT',
        data
    })
}

//封装删除角色用户
export function getDel(id) {
    return request({
        url: `/roles/${id}`,
        method: 'delete',
    })
}
//封装商品列表
export function getGoodsApi(params) {
    return request({
        url: '/goods',
        method: 'get',
        params
    })
}

//删除商品
export function getdelApi(id) {
    return request({
        url: `goods/${id}`,
        method: 'delete',
        
    })
}

//封装订单列表
export function getOrderApi(params) {
    return request({
        url: '/orders',
        method: 'get',
        params
    })
}

//封装删除角色权限
export function getDelRole(roleId, rightId) {
    return request({
        url: `/roles/${roleId}/rights/${rightId}`,
        method: 'delete'
    })
}

//调用树形权限接口
export function getRights() {
    return request({
        url: `/rights/tree`,
        method: 'get',
    })
}

export function setRightsToRoleAPI(roleId, data) {
    return request({
        url: `/roles/${roleId}/rights`,
        method: 'POST',
        data
    })
}

//获取商品分类
export function getCateListAPI(params = {}) {
    return request({
        url: `/categories`,
        method: 'get',
        params
    })
}

//商品分类
export function getTowCateList() {
    // console.log(id); 
    return request({
        url: `/categories`,
        method: 'GET',
        params: {
            type: 2
        }
    })
}
//删除分类
export function getTowCateReomve(id) {
    // console.log(id); 
    return request({
        url: `/categories/${id}`,
        method: 'delete',

    })
}

//编译提交
export function cateApi(id, data) {
    // console.log(id); 
    return request({
        url: `/categories/${id}`,
        method: 'put',
        data
    })
}
//提交商品分类
export function addCateApi(data) {
    // console.log(id); 
    return request({
        url: `/categories`,
        method: 'post',
        data
    })
}


//分类参数
export function getParameter(id, params) {
    // console.log(id); 
    return request({
        url: `/categories/${id}/attributes`,
        method: 'GET',
        params
    })
}
//添加动态参数或者静态属性
export function getAttribDyn(id, data) {
    return request({
        url: `/categories/${id}/attributes`,
        method: 'POST',
        data
    })
}
//修改动态参数或者静态属性
export function getAttribDynSon(id, attrId, data) {
    console.log(id);
    console.log(attrId);
    console.log(data);
    return request({
        url: `/categories/${id}/attributes/${attrId}`,
        method: 'put',
        data
    })
}

export function getAttribRemove(id, attrId) {
    console.log(attrId);
    return request({
        url: `/categories/${id}/attributes/${attrId.attrId}`,
        method: 'delete',
    })
}


//添加商品接口
export function addGoodsAPI(data) {
    console.log(data);
    return request({
        url: "goods",
        method: "POST",
        data,
    });
}

//查看流程数据接口
export function getKuaDiProgressAPI() {
  return request({
    //真实情况下，/kuaidi/:id 其中的id是每个订单号返回的数据，这里的1106975712662只是一个测试物流
    url: "https://www.liulongbin.top:8888/api/private/v1/kuaidi/1106975712662",
    method: "GET",
  });
}


export function getEchartsAPI() {
    return request({
        url: 'reports/type/1',
        method: 'GET'
    })
}
